# Generated by Django 4.2.1 on 2023-10-30 16:46

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='TaskRunLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('task_id', models.CharField(editable=False, max_length=128)),
                ('task_type', models.CharField(choices=[('ScheduledJob', 'ScheduledJob'), ('RepeatableJob', 'RepeatableJob'), ('CronJob', 'CronJob')], editable=False, max_length=128)),
                ('job_id', models.CharField(blank=True, editable=False, max_length=128)),
                ('result', models.JSONField(blank=True, null=True)),
                ('status', models.CharField(max_length=50)),
                ('errors', models.JSONField(blank=True, null=True)),
                ('ends_at', models.DateTimeField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'ordering': ('-created_at',),
            },
        ),
        migrations.CreateModel(
            name='ScheduledJob',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('name', models.CharField(max_length=512, unique=True)),
                ('callable', models.CharField(max_length=2048)),
                ('callable_args', models.TextField(blank=True, null=True)),
                ('callable_kwargs', models.TextField(blank=True, null=True)),
                ('enabled', models.BooleanField(default=True)),
                ('queue', models.CharField(choices=[('default', 'default')], max_length=32)),
                ('job_id', models.CharField(blank=True, editable=False, max_length=128, null=True)),
                ('timeout', models.IntegerField(blank=True, help_text="Timeout specifies the maximum runtime, in seconds, for the job before it'll be considered 'lost'. Blank uses the default timeout.", null=True)),
                ('status', models.CharField(choices=[('queued', 'queued'), ('started', 'started'), ('finished', 'finished'), ('failed', 'failed'), ('deferred', 'deferred')], default='queued', max_length=50)),
                ('result_ttl', models.IntegerField(blank=True, help_text='The TTL value (in seconds) of the job result. -1: Result never expires, you should delete jobs manually. 0: Result gets deleted immediately. >0: Result expires after n seconds.', null=True)),
                ('task_category', models.CharField(choices=[('generic', 'generic'), ('app_run', 'app_run'), ('data_refresh', 'data_refresh')], default='generic', editable=False, max_length=128)),
                ('metadata', models.JSONField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('scheduled_time', models.DateTimeField()),
                ('owner', models.ForeignKey(help_text='Owner of the task', on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Scheduled Job',
                'verbose_name_plural': 'Scheduled Jobs',
                'ordering': ('name',),
            },
        ),
        migrations.CreateModel(
            name='RepeatableJob',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('name', models.CharField(max_length=512, unique=True)),
                ('callable', models.CharField(max_length=2048)),
                ('callable_args', models.TextField(blank=True, null=True)),
                ('callable_kwargs', models.TextField(blank=True, null=True)),
                ('enabled', models.BooleanField(default=True)),
                ('repeat', models.PositiveIntegerField(blank=True, help_text='Number of times to repeat the job. Blank repeats forever.', null=True)),
                ('queue', models.CharField(choices=[('default', 'default')], max_length=32)),
                ('job_id', models.CharField(blank=True, editable=False, max_length=128, null=True)),
                ('timeout', models.IntegerField(blank=True, help_text="Timeout specifies the maximum runtime, in seconds, for the job before it'll be considered 'lost'. Blank uses the default timeout.", null=True)),
                ('status', models.CharField(choices=[('queued', 'queued'), ('started', 'started'), ('finished', 'finished'), ('failed', 'failed'), ('deferred', 'deferred')], default='queued', max_length=50)),
                ('result_ttl', models.IntegerField(blank=True, help_text='The TTL value (in seconds) of the job result. -1: Result never expires, you should delete jobs manually. 0: Result gets deleted immediately. >0: Result expires after n seconds.', null=True)),
                ('task_category', models.CharField(choices=[('generic', 'generic'), ('app_run', 'app_run'), ('data_refresh', 'data_refresh')], default='generic', editable=False, max_length=128)),
                ('metadata', models.JSONField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('scheduled_time', models.DateTimeField()),
                ('interval', models.PositiveIntegerField()),
                ('interval_unit', models.CharField(choices=[('minutes', 'minutes'), ('hours', 'hours'), ('days', 'days'), ('weeks', 'weeks')], default='hours', max_length=12)),
                ('owner', models.ForeignKey(help_text='Owner of the task', on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Repeatable Job',
                'verbose_name_plural': 'Repeatable Jobs',
                'ordering': ('name',),
            },
        ),
        migrations.CreateModel(
            name='CronJob',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('name', models.CharField(max_length=512, unique=True)),
                ('callable', models.CharField(max_length=2048)),
                ('callable_args', models.TextField(blank=True, null=True)),
                ('callable_kwargs', models.TextField(blank=True, null=True)),
                ('enabled', models.BooleanField(default=True)),
                ('repeat', models.PositiveIntegerField(blank=True, help_text='Number of times to repeat the job. Blank repeats forever.', null=True)),
                ('queue', models.CharField(choices=[('default', 'default')], max_length=32)),
                ('job_id', models.CharField(blank=True, editable=False, max_length=128, null=True)),
                ('timeout', models.IntegerField(blank=True, help_text="Timeout specifies the maximum runtime, in seconds, for the job before it'll be considered 'lost'. Blank uses the default timeout.", null=True)),
                ('status', models.CharField(choices=[('queued', 'queued'), ('started', 'started'), ('finished', 'finished'), ('failed', 'failed'), ('deferred', 'deferred')], default='queued', max_length=50)),
                ('result_ttl', models.IntegerField(blank=True, help_text='The TTL value (in seconds) of the job result. -1: Result never expires, you should delete jobs manually. 0: Result gets deleted immediately. >0: Result expires after n seconds.', null=True)),
                ('task_category', models.CharField(choices=[('generic', 'generic'), ('app_run', 'app_run'), ('data_refresh', 'data_refresh')], default='generic', editable=False, max_length=128)),
                ('metadata', models.JSONField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('cron_string', models.CharField(help_text='Define the schedule in a crontab like syntax.', max_length=64)),
                ('owner', models.ForeignKey(help_text='Owner of the task', on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Cron Job',
                'verbose_name_plural': 'Cron Jobs',
                'ordering': ('name',),
            },
        ),
    ]
